var _n45;
var cc__extends = __extends;
var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_TrajectoryController = function (t) {
  function _ctor() {
    const result = null !== t && t.apply(this, arguments) || this; // 使用更具描述性的变量名

    // 初始化属性
    result.ropeController = null;
    result.ropeControllerComp = null;

    return result;
  }
  cc__extends(_ctor, t);
  _ctor.prototype.onLoad = function () {
    if (this.ropeController) {
      // 获取 RopeTexture 组件
      this.ropeControllerComp = this.ropeController.getComponent("RopeTexture");

      if (this.ropeControllerComp) {
        // 注册鼠标移动事件
        this.node.on(cc.Node.EventType.MOUSE_MOVE, this.onMouseMove, this);
      } else {
        cc.error("未找到RopeTexture组件！");
      }
    } else {
      cc.error("未设置绳子控制器节点！");
    }
  };
  _ctor.prototype.onDestroy = function () {
    this.node.off(cc.Node.EventType.MOUSE_MOVE, this.onMouseMove, this);
  };
  _ctor.prototype.onMouseMove = function (t) {
    if (this.ropeControllerComp) {
      const touchLocation = t.getLocation(); // 获取触摸位置
      const localPosition = this.ropeController.convertToNodeSpaceAR(touchLocation); // 转换为本地坐标
      this.ropeControllerComp.updateEndPoint(localPosition.x, localPosition.y); // 更新终点
    }
  };
  cc__decorate([ccp_property({
    type: cc.Node,
    tooltip: "绳子控制器节点",
    displayName: "绳子控制器"
  })], _ctor.prototype, "ropeController", undefined);
  return cc__decorate([ccp_ccclass], _ctor);
}(cc.Component);
exports.default = def_TrajectoryController;